use std::{future::Future, pin::Pin};

struct Test {
    str1: Pin<Box<String>>,
    str2: *const String,
}

impl Test {
    fn new(str: &str) -> Self {
        Test {
            str1: Box::pin(String::from(str)),
            str2: std::ptr::null(),
        }
    }
    fn init(&mut self) {
        let a = &*self.str1;
        self.str2 = a;
    }
    fn str1(&self) -> &String {
        &self.str1
    }

    fn str2(&self) -> &String {
        return unsafe {
            let a = &*self.str2;
            return a;
        };
    }
}

pub fn test() {
    let mut a = Test::new("a");
    a.init();
    let mut b = Test::new("b");
    b.init();
    std::mem::swap(&mut a, &mut b);
    println!("{} {}", a.str1(), a.str2());
    println!("{} {}", b.str1(), b.str2());
    //drop(b);
    //println!("{}",a.str2());
}

type CallBack = Box<dyn Fn(i32) -> Pin<Box<dyn Future<Output = i32>>>>;

pub async fn test2(c: CallBack) {
    let a=c(1).await;
}
